package com.yqy.android;

import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.android.base.base.BaseTitleActivity;

import butterknife.OnClick;

public abstract class BaseHomeActivity extends BaseTitleActivity implements View.OnClickListener{

    protected FrameLayout mHomeContent;
    protected TextView mHomeTabIm;
    protected TextView mHomeTabFoot;
    protected TextView mHomeTabTeam;
    protected TextView mHomeTabMap;
    protected TextView mHomeTabMine;
    protected TextView mUnreadMsgNumber;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();

        initNavigationBar();
    }

    protected abstract int getCurrentPage();

    private void initView(){
        mHomeContent = (FrameLayout) findViewById(R.id.home_content);
        mHomeTabIm = (TextView) findViewById(R.id.home_tab_im);
        mHomeTabIm.setOnClickListener(this);
        mHomeTabFoot = (TextView) findViewById(R.id.home_tab_foot);
        mHomeTabFoot.setOnClickListener(this);
        mHomeTabTeam = (TextView) findViewById(R.id.home_tab_team);
        mHomeTabTeam.setOnClickListener(this);
        mHomeTabMap = (TextView) findViewById(R.id.home_tab_map);
        mHomeTabMap.setOnClickListener(this);
        mHomeTabMine = (TextView) findViewById(R.id.home_tab_mine);
        mHomeTabMine.setOnClickListener(this);
        mUnreadMsgNumber = (TextView) findViewById(R.id.unread_msg_number);
    }
    /**
     * 初始化导航栏
     * */
    private void initNavigationBar(){
        switch (getCurrentPage()){
            case 0:
                mHomeTabIm.setTextColor(getResources().getColor(R.color.tab_color_pressed));
                mHomeTabIm.setCompoundDrawablesWithIntrinsicBounds(null,
                        getResources().getDrawable(R.mipmap.home_tab_im_pressed), null, null);
                break;
            case 1:
                mHomeTabFoot.setTextColor(getResources().getColor(R.color.tab_color_pressed));
                mHomeTabFoot.setCompoundDrawablesWithIntrinsicBounds(null,
                        getResources().getDrawable(R.mipmap.home_tab_im_pressed), null, null);
                break;
            case 2:
                mHomeTabTeam.setTextColor(getResources().getColor(R.color.tab_color_pressed));
                mHomeTabTeam.setCompoundDrawablesWithIntrinsicBounds(null,
                        getResources().getDrawable(R.mipmap.home_tab_im_pressed), null, null);
                break;
            case 3:
                mHomeTabMap.setTextColor(getResources().getColor(R.color.tab_color_pressed));
                mHomeTabMap.setCompoundDrawablesWithIntrinsicBounds(null,
                        getResources().getDrawable(R.mipmap.home_tab_im_pressed), null, null);
                break;
            case 4:
                mHomeTabMine.setTextColor(getResources().getColor(R.color.tab_color_pressed));
                mHomeTabMine.setCompoundDrawablesWithIntrinsicBounds(null,
                        getResources().getDrawable(R.mipmap.home_tab_im_pressed), null, null);
                break;
        }
    }

    @Override
    protected void initHeaderTitle() {

    }

    @Override
    public int pageStyle() {
        return 1;
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_base_home;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.home_tab_im:
                //通讯
                break;
            case R.id.home_tab_foot:
                //足迹
                break;
            case R.id.home_tab_team:
                //加团
                break;
            case R.id.home_tab_map:
                //地图
                break;
            case R.id.home_tab_mine:
                //个人
                break;
        }
    }
}
